import Vue from 'vue'
import Router from 'vue-router'
import Login from '@/components/Login'
import Home from "@/components/Home"
import Main from '@/components/page/Main'
import ChooseCourse from "@/components/studentView/ChooseCourse";
import StudentCourse from "@/components/studentView/StudentCourse";
import CourseTable from "@/components/studentView/CourseTable";
import StudentScore from "@/components/studentView/StudentScore";
import StuUpdateInfo from "@/components/studentView/StuUpdateInfo";
import TeacherCourse from "@/components/TeacherView/TeacherCourse";
import TeacherTable from "@/components/TeacherView/TeacherTable";
import TeacherAddScore from "@/components/TeacherView/TeacherAddScore";
import CourseManager from "@/components/AdminView/CourseManager";

Vue.use(Router)

// 解决ElementUI导航栏中的vue-router在3.0版本以上重复点菜单报错问题
const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

export default new Router({
  routes: [
    {
      path: '/',
      name: 'Login',
      component: Login
    },
    {
      path: '/Home',
      component: Home,
      children: [
        {
          path: '/',
          name: 'Main',
          component: Main
        },
        {
          path: '/ChooseCourse',
          name: 'ChooseCourse',
          component: ChooseCourse
        },
        {
          path: '/StudentCourse',
          name: 'StudentCourse',
          component: StudentCourse
        },
        {
          path: '/CourseTable',
          name: 'CourseTable',
          component: CourseTable
        },
        {
          path: '/StudentScore',
          name: 'StudentScore',
          component: StudentScore
        },
        {
          path: '/StuUpdateInfo',
          name: 'StuUpdateInfo',
          component: StuUpdateInfo
        },
        {
          path: '/TeacherCourse',
          name: 'TeacherCourse',
          component: TeacherCourse
        },
        {
          path: '/TeacherTable',
          name: 'TeacherTable',
          component: TeacherTable
        },
        {
          path: '/TeacherAddScore',
          name: 'TeacherAddScore',
          component: TeacherAddScore
        },
        {
          path: '/CourseManager',
          name: 'CourseManager',
          component: CourseManager
        }
      ]
    }

  ]
})

